﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cstdx.Internal;

public static  class SequenceGenerator
{
	// 用于生成序列号的原子变量，初始值为0
	private static uint _seqId = 0;

	/// <summary>
	/// 生成自增的序列号
	/// </summary>
	/// <returns>新的序列号（从1开始自增）</returns>
	public static uint SequenceId()
	{
		// 原子操作：先增加1再返回新值，确保线程安全
		return Interlocked.Increment(ref _seqId);
	}
}
